package graph_viewer.drawer;

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Font;
import java.awt.FontMetrics;

import graph_viewer.structure.Node;
import graph_viewer.structure.Node_Position;
import graph_viewer.structure.Visual_Component;

import graph_viewer.util.*;

/**
	Define method to draw a node, the drawing is done by Node_Drawer_Handler in subclasses.
*/
public abstract class Node_Drawer implements Component_Drawer{

	//=================================================
	// hooker methods
	//=================================================
	abstract protected void draw_node(Node node, Graphics2D g, int k );
	abstract protected void draw_node_label( Node node, final Graphics2D g );

	//=================================================
	// public interface
	//=================================================

	/**
	 * Draw a visual component. The interface of Component Drawers
	 * The hooker method in template pattern
	 * 
	 * @param component
	 */
	public void draw(Visual_Component component, Graphics g, int k){
		Node node =(Node)component;		
		
		// the abstract method needed implemented by subclass
		Graphics2D g2d = (Graphics2D)g;

		draw_node(node, g2d, k );				
		draw_node_info( node, g2d );
	}

	public void draw(Visual_Component component, Graphics2D g ){
		draw( component, g, 1000 );
	}
	
	//=================================================
	// protected methods
	//=================================================
	protected void draw_node_info( Node node, Graphics2D g ){	
		//Debug.println( "Node_Drawer.draw_draw_node_info: " + node.get_label(), 2 );
		draw_node_label( node, g );
	}
	
}